package com.bxait.toymail.member.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/*
@description: 关于springSession的配置
@ClassName ToyMailSessionConfig
@author Chen
@create 2023-04-21 11:00
@Version 1.0
*/
@Configuration
public class ToyMailSessionConfig {
    /*
     * @param
     * @==============History===============<br/>
     * @Description //   配置cookie序列化的配置
     * @Date 2023/4/21 2023/4/21
     * @Author < a href="2277411582@qq.com">chen</ a>
     * @return
     */
    @Bean
    public CookieSerializer cookieSerializer() {
        DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
//        // 设置cookie放大到父域名
//        cookieSerializer.setDomainName("toymail.com");
//        // 设置cookie的名称
//        cookieSerializer.setCookieName("TOYMAILSESSION");
        return cookieSerializer;
    }

    /*
     * @param
     * @==============History===============<br/>
     * @Description //   将数据缓存到redis中的序列化机制选择json的序列化机制
     * @Date 2023/4/21 2023/4/21
     * @Author < a href="2277411582@qq.com">chen</ a>
     * @return
     */
    @Bean
    public RedisSerializer<Object> springSessionDefaultRedisSerializer() {
        return new GenericJackson2JsonRedisSerializer();
    }
}